package com.ming.interview;

/**
 * @Description 题目：判断101-200之间有多少个素数，并输出所有素数。
 * @Author ye.ming
 * @Date Created in 2019/8/26
 */
public class Main2 {

    public static void main(String[] args) {
        int sum = 0;
        for (int i = 100; i < 201; i++) {
            if (isRightNum(i)) {
                System.out.print(i + " ");
                sum++;
                if (sum % 10 == 0) {
                    System.out.println();
                }
            }
        }
    }


    private static boolean isRightNum(int n) {
        int top = (int) Math.sqrt(n);
        for (int i = 2; i <= top; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }


}
